﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HR60_PanelSoft.View.TabForms;

namespace HR60_PanelSoft.View
{
	public partial class WindowNew : Form
	{
		NewDeviceForm newDeviceForm = new NewDeviceForm();

		NewPanelForm newPanelForm = new NewPanelForm();

		WindowMain winMain = null;

		public WindowNew(WindowMain winMain)
		{
			InitializeComponent();
			this.winMain = winMain;
			newDeviceForm.Dock = DockStyle.Fill;
			newPanelForm.Dock = DockStyle.Fill;

			newDeviceForm.refreshFormData();
			newPanelForm.refreshFormData();
		}

		public void showNewPanel()
		{
			this.Text = "添加面板";
			panelMain.Controls.Clear();
			panelMain.Controls.Add(newPanelForm);
			this.ShowDialog(winMain);
		}

		public void showNewDevice()
		{
			this.Text = "添加设备";
			panelMain.Controls.Clear();
			panelMain.Controls.Add(newDeviceForm);
			this.ShowDialog(winMain);
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			if (this.Text == "添加面板")
			{
				winMain.doCreateNewPanel(newPanelForm.getFields());
				this.Hide();
			}
			else
			{
				winMain.doCreateNewDevice(newDeviceForm.getFields());
				this.Hide();
			}
		}

		private void btnCanel_Click(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}
